
function initAccuse() {
    $.ajax({
        url: "functions/ajax/getAgentList.php",
        context: self,
        type: "post",
        success: function(data, textStatus, jqXHR) {
            var agentArray = jQuery.parseJSON(data);

            var agentSelect = $("select#agentGuessList");

            // first remove the current markers
            for (var i=0; i<agentArray.length; i++) {
                agentSelect.append("<option>"+agentArray[i].name+"</option>");
            }

            agentSelect.selectmenu('refresh');
        }
    });
}

$('#accuse').live('pageinit',function(event){
    initAccuse();

    $("a#arrestButton").unbind('click');
    $("a#arrestButton").click(function() {
        var chosenName = $("select#agentGuessList option:selected").val();
        $.mobile.changePage("end.php", {
            data: {
                      name: chosenName
                  }
        });
    });
});

